//////////jq.js
//http://172.16.7.66:8080/yl
//http://x3q4qh.natappfree.cc/yl
var serviceUrl = 'https://newsales.chinaesf.net/yl';
var serviceUrl2 = 'http://newsales.chinaesf.net:8083';
var ajaxTimeout=30000;


function showVanLoading(msg){
	if(msg==undefined || msg==null || msg==''){
		msg='加载中...';
	}
	vant.Toast.loading({
		message: msg,
		duration:0,
		forbidClick: true,
		loadingType: 'spinner',
	});
};
function closeVanLoading(){
	vant.Toast.clear();
}

/**
 * 获取指定的URL参数值 
 * URL:http://www.quwan.com/index?name=tyler 
 * 参数：paramName URL参数 
 * 调用方法:getParam("name") 
 * 返回值:tyler 
 */
function getParam(paramName) {
	paramValue = "", isFound = !1;
	if(this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
		arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
		while(i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
	}
	return paramValue == "" && (paramValue = null), paramValue
}

//请求数据(提交JSON数据)
var _postHttpsData = function(actionUrl, param, funRecall, errFunRecall) {
	var url = serviceUrl + actionUrl;
	var token = window.localStorage.getItem("token");
	$.ajax({
		url : url,
		async : 'true',
		type : 'post',
		data : param,
		jsonp : 'callback',
		dataType : 'json',
		timeout:ajaxTimeout,
		contentType:'application/json;charset=utf-8',
		beforeSend:function(request){
			request.setRequestHeader("token", token);
		},
		success : function(data) {
			funRecall(data);
		},
		error : function(err) {			
			errFunRecall(err);
		}
	});

}

//请求数据(提交JSON数据)
var _getHttpsData = function(actionUrl, param, funRecall, errFunRecall) {
	var url = serviceUrl + actionUrl;
	// if(param!=undefined && param!=null && param.length>0){
	// 	url=url+'?'+param;
	// }
	var token = window.localStorage.getItem("token");
	$.ajax({
		url : url,
		async : 'true',
		type : 'get',
		data:param,
		jsonp : 'callback',
		dataType : 'json',
		timeout:ajaxTimeout,
		contentType:'application/json;charset=utf-8',
		beforeSend:function(request){
			request.setRequestHeader("token", token);
		},
		success : function(data) {
			funRecall(data);
		},
		error : function(err) {
			errFunRecall(err);
		}
	});

}

//请求数据(提交JSON数据)
var _getHttpsData2 = function(actionUrl, param, funRecall, errFunRecall) {
	var url = serviceUrl2 + actionUrl;
	// if(param!=undefined && param!=null && param.length>0){
	// 	url=url+'?'+param;
	// }
	var token = window.localStorage.getItem("token");
	$.ajax({
		url : url,
		async : 'true',
		type : 'get',
		data:param,
		jsonp : 'callback',
		dataType : 'json',
		timeout:ajaxTimeout,
		contentType:'application/json;charset=utf-8',
		beforeSend:function(request){
			request.setRequestHeader("token", token);
		},
		success : function(data) {
			funRecall(data);
		},
		error : function(err) {
			errFunRecall(err);
		}
	});

}

//请求数据(提交JSON数据)
var _getHttpsDataP = function(actionUrl, param, funRecall, errFunRecall) {
	var url = serviceUrl + actionUrl;
	// if(param!=undefined && param!=null && param.length>0){
	// 	url=url+'?'+param;
	// }
	var token = window.localStorage.getItem("token");
	$.ajax({
		url : url,
		async : 'true',
		type : 'get',
		data:param,
		jsonp : 'callback',
		dataType : 'json',
		timeout:ajaxTimeout,
		contentType:'application/json;charset=utf-8',
		beforeSend:function(request){
			request.setRequestHeader("token", token);
		},
		success : function(data) {
			funRecall(data);
		},
		error : function(err) {
			errFunRecall(err);
		}
	});

}



